<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

/**
 * 用户个人设置控制器
 *
 * Class SettingController
 * @package App\Http\Controllers
 */
class SettingController extends Controller
{
    /**
     * SettingController constructor.
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**展示用户的个人设置
     *
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(){
        return view('users.setting');
    }

    /**
     * 保存个人设置的操作
     *
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(Request $request){
        user()->settings()->merge($request->all());
        return redirect()->route('host', user()->id)->with('success', '个人资料更新成功！');
    }
}
